package model

import "k8s.io/apimachinery/pkg/util/sets"

// function

const (
	MaxFunctionMemory          = 3072
	MinFunctionMemory          = 128
	FunctionMemoryInterval     = 128
	VersionLabelKey            = "fc-function-version"
	FunctionNameLabelKey       = "serving.knative.dev/service"
	FunctionIdLabelKey         = "fc-function-id"
	GroupIdLabelKey            = "fc-group-id"
	FunctionHandlerLabelKey    = "fc-function-handler"
	FunctionRuntimeLabelKey    = "fc-runtime"
	FunctionRuntimeTagLabelKey = "fc-runtime-tag"
	FunctionNamespaceKey       = "fc-namespace"
	InitializeHandlerLabelKey  = "fc-initialize-handler"
	InitializeTimeoutLabelKey  = "fc-initialize-timeout"
	KataContainerAnnotationKey = "io.kubernetes.cri.untrusted-workload"
	FunctionLatestVersion      = "LATEST"
	InvokeEventType            = "invoke"
	InvokeEventSource          = "fc_admin/invoke"
	// BuckerName              = "fcs-code"
	FunctionNamespacePrefix = "fc"
	// KongUrl                 = "kong-proxy.knative-kong"
	DefaultBroker         = "default"
	MinScaleAnnotationKey = "autoscaling.knative.dev/minScale"
	MaxScaleAnnotationKey = "autoscaling.knative.dev/maxScale"
	GpuLimitName          = "nvidia.com/gpu"
	GpuTypeName           = "gpu-type"
	GpuCommonType         = "any"
	MaterNodeLabelKey     = "node-role.kubernetes.io/master"
	LayerAnnotationKey    = "layerPath"
	LayerUsedLabelKey     = "useLayer"
	NFSNodeLabelKey       = "nfs-server"
	ICPLabelKey           = "icp"
	Service               = "fcs"
	NodeIntIPStr          = "InternalIP"
)

// runtime
const (
	Python36   = "python3.6"
	Python27   = "python2.7"
	NodeJs1022 = "nodejs10.22"
	NodeJS1218 = "nodejs12.18"
	Golang1    = "golang1"
	Java8      = "java8"
	PHP        = "php"

	CustomContainer = "custom-container"

	DefaultUserContainerPort = "8080"

	DefaultRegistrySecretName = "fcs-registry-credential"
)

// metric
const (
	InvokeCount      = "invocation"
	InvokeDuration   = "duration"
	InvokeMemory     = "memory"
	InvokeErrorCount = "error"
	InvokeSuccess    = "success"
	InvokeFailure    = "failure"
)

// knative
const (
	RevisionGenerationLabel = "serving.knative.dev/configurationGeneration"
	KsvcReadyTime           = 120
	KsvcMemUnit             = "Mi"
)

const (
	PublicLabelKey = "public"
)

const (
	ServerPortNumber     = 24
	EthNameAnnotationKey = "ticket.eth.name"
	CIDRAnnotationKey    = "ticket.eth.cidr"
	GWAnnotationKey      = "ticket.eth.gateway"
	RemoteAnnotationKey  = "ticket.eth.remote"
	MACAnnotationKey     = "ticket.eth.mac"
)

const (
	FunctionCreating = "creating"
	FunctionSuccess  = "success"
	FunctionFailure  = "failure"
	FunctionUpdating = "updating"
)

// trigger
const (
	OssMqExchange  = "exchange.fcs"
	OssMqQueue     = "queue.fcs.oss"
	OssMqRk        = "key.fcs.oss"
	OssEventType   = "oss"
	OssEventSource = "fc_admin/oss"

	TargetTypeVersion = 1
	TargetTypeAlias   = 2

	HttpTriggerAuthTypeIAM = "iam"
)

// Kong Cluster Plugin
const (
	KCPBss         = "plugin-fcs-bss"
	KCPCredential  = "plugin-fcs-credential"
	KCPIam         = "plugin-fcs-iam"
	KCPCorsDefault = "plugin-fcs-cors-default"
	KCPCorsCname   = "plugin-fcs-cors-cname"
)

var RuntimeSet = sets.NewString(Python36, NodeJs1022, Python27, NodeJS1218, Golang1, Java8, PHP, CustomContainer)

// custom-container 用户容器不支持的监听端口
var UserContainerPortSet = sets.NewString("8012", "8013", "8022", "9090", "9091", "9092")

func GetMetricMap() map[string]bool {
	metricMap := make(map[string]bool)
	metricMap[InvokeCount] = true
	metricMap[InvokeDuration] = true
	metricMap[InvokeMemory] = true
	metricMap[InvokeErrorCount] = true
	return metricMap
}

type VpcUpdateStatus int

const (
	Vpc_No_Need_Update VpcUpdateStatus = 0
	Vpc_Need_Add       VpcUpdateStatus = 1
	Vpc_Need_Delete    VpcUpdateStatus = 2
	Vpc_Need_Modify    VpcUpdateStatus = 3
)

// extGroupId
const (
	ExtIds = "ids"
)
